const http = require('http');

const server = http.createServer(function (req, res) {
  const url = 'http://www.baidu.com';
  const body = `<p>Redirecting to <a href="${url}"></a></p>`;
  res.setHeader('Location', url);
  res.setHeader('Content-Length', body.length);
  res.setHeader('Content-Type', 'text/plain');
  res.statusCode = 302;
  res.end(body);
});
server.listen(3000);
